{"ast":null,"code":"import _slicedToArray from\"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/slicedToArray.js\";import type from\"tinycolor2\";import{Md5}from'ts-md5';var getCorrectIndex=function getCorrectIndex(number){return number>255?255:number<0?0:number;};export var generateAvatarByNickname=function generateAvatarByNickname(nickname){var hash=Md5.hashStr(nickname);var _hash$substring$split=hash.substring(0,3).split(\"\").map(function(char){return getCorrectIndex(char.charCodeAt(0));}),_hash$substring$split2=_slicedToArray(_hash$substring$split,3),r=_hash$substring$split2[0],g=_hash$substring$split2[1],b=_hash$substring$split2[2];return{colors:{color:type({r:r,g:g,b:b}).lighten(10).saturate(10).toHexString(),colorLighten:type({r:r,g:g,b:b}).lighten(30).saturate(30).toHexString()}};};export default generateAvatarByNickname;","map":{"version":3,"names":["type","Md5","getCorrectIndex","number","generateAvatarByNickname","nickname","hash","hashStr","substring","split","map","char","charCodeAt","r","g","b","colors","color","lighten","saturate","toHexString","colorLighten"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/src/utils/helpers/generateAvatarByNickname.ts"],"sourcesContent":["import type from \"tinycolor2\";\nimport {Md5} from 'ts-md5';\n\nconst getCorrectIndex = (number: number) => {\n    return (number > 255)? 255: (number < 0)? 0 : number;\n};\n\nexport const generateAvatarByNickname = (nickname: string) => {\n    const hash = Md5.hashStr(nickname);\n    const [r, g, b] = hash.substring(0, 3).split(\"\").map(char => getCorrectIndex(char.charCodeAt(0)));\n\n    return {\n        colors: {\n            color: type({ r, g, b })\n                .lighten(10)\n                .saturate(10)\n                .toHexString(),\n            colorLighten: type({ r, g, b })\n                .lighten(30)\n                .saturate(30)\n                .toHexString()\n        }\n    };\n};\n\nexport default generateAvatarByNickname;"],"mappings":"8IAAA,MAAOA,KAAI,KAAM,YAAY,CAC7B,OAAQC,GAAG,KAAO,QAAQ,CAE1B,GAAMC,gBAAe,CAAG,QAAlBA,gBAAe,CAAIC,MAAc,CAAK,CACxC,MAAQA,OAAM,CAAG,GAAG,CAAG,GAAG,CAAGA,MAAM,CAAG,CAAC,CAAG,CAAC,CAAGA,MAAM,CACxD,CAAC,CAED,MAAO,IAAMC,yBAAwB,CAAG,QAA3BA,yBAAwB,CAAIC,QAAgB,CAAK,CAC1D,GAAMC,KAAI,CAAGL,GAAG,CAACM,OAAO,CAACF,QAAQ,CAAC,CAClC,0BAAkBC,IAAI,CAACE,SAAS,CAAC,CAAC,CAAE,CAAC,CAAC,CAACC,KAAK,CAAC,EAAE,CAAC,CAACC,GAAG,CAAC,SAAAC,IAAI,QAAIT,gBAAe,CAACS,IAAI,CAACC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAC,gEAA1FC,CAAC,2BAAEC,CAAC,2BAAEC,CAAC,2BAEd,MAAO,CACHC,MAAM,CAAE,CACJC,KAAK,CAAEjB,IAAI,CAAC,CAAEa,CAAC,CAADA,CAAC,CAAEC,CAAC,CAADA,CAAC,CAAEC,CAAC,CAADA,CAAE,CAAC,CAAC,CACnBG,OAAO,CAAC,EAAE,CAAC,CACXC,QAAQ,CAAC,EAAE,CAAC,CACZC,WAAW,EAAE,CAClBC,YAAY,CAAErB,IAAI,CAAC,CAAEa,CAAC,CAADA,CAAC,CAAEC,CAAC,CAADA,CAAC,CAAEC,CAAC,CAADA,CAAE,CAAC,CAAC,CAC1BG,OAAO,CAAC,EAAE,CAAC,CACXC,QAAQ,CAAC,EAAE,CAAC,CACZC,WAAW,EACpB,CACJ,CAAC,CACL,CAAC,CAED,cAAehB,yBAAwB"},"metadata":{},"sourceType":"module"}